home *** CD-ROM | disk | FTP | other *** search
/ Amiga Packmags / NewsFlash - Issue 07 (1990-01)(UGA - 17-Bit Software)(Disk 1 of 2)[a intro].zip / NewsFlash - Issue 07 (1990-01)(UGA - 17-Bit Software)(Disk 1 of 2)[a intro].adf / sources / Bobs.S next >
Text File  |  1996-12-24  |  9KB  |  313 lines

  1. ; Scroller+Bobs
  2. ; (C)1989 by Brian Postma
  3. ; J.v.Hartenstraat 51
  4. ; 7576VX Oldenzaal (NL)
  5. ; Tel:05410-14763
  6.  
  7. start:    movem.l        d0-d7/a0-a6,-(a7)
  8.     bsr        initcop        ;Init CopperList
  9.     lea        gfxname,a1    ;Name of graphics library
  10.     move.l        4,a6        ;Execbase
  11.     jsr        -132(a6)    ;Forbid->No Multitasking
  12.     jsr        -408(a6)    ;Open Library
  13.     move.l        d0,gfxbase    ;Rememer graphics base
  14.     lea        intname,a1    ;Name of intuition lib.
  15.     jsr        -408(a6)    ;Open Library
  16.     move.l        d0,intbase    ;Remember intuition base
  17.     move.l        intbase,a6
  18.     lea        osargs,a0    ;Pointer to newscreen struct.
  19.     jsr        -198(a6)    ;Open Screen
  20.     move.l        d0,screenbase    ;Pointer to screen struct
  21.     beq        quit        ;Could I open it ??
  22.     add.l        #84,d0        ;Screenbase+84
  23.     move.l        d0,rastport    ;Is Rastport
  24.     move.l        gfxbase,a6    
  25.     move.l        rastport,a1
  26.     clr.l        d0        ;Color=0
  27.     jsr        -234(a6)    ;Setrast->Clear Screen
  28.     move.l        screenbase,a0
  29.     move.l        192(a0),d0    ;Pointer to first bitplane
  30.     move.w        d0,planes+6    ;Low word in copperlist
  31.     swap        d0
  32.     move.w        d0,planes+2    ;High word in copperlist
  33.     move.l        gfxbase,a0    ;gfxbase+$32=pointer to clist
  34.     move.l        $32(a0),oldcop    ;save old copperlist
  35.     move.l        #newcop,$32(a0)    ;My own copperlist
  36.     move.l        $6c,oldirq    ;Save old VBL irq pointer
  37.     move.l        #newirq,$6c    ;my VBL interrupt
  38. wait:    btst        #6,$bfe001    ;Left mouse button pressed ??
  39.     bne        wait        ;No !!
  40.     move.l        oldirq,$6c    ;Restore interrupt
  41.     move.l        gfxbase,a0    ;restore
  42.     move.l        oldcop,$32(a1)    ;old copperlist
  43.     move.l        intbase,a6
  44.     move.l        screenbase,a0
  45.     jsr        -66(a6)        ;Close the screen
  46.     move.l        4,a6
  47.     jsr        -138(a6)    ;Permit->Multitasking on
  48. quit:    movem.l        (a7)+,d0-d7/a0-a6
  49.     rts
  50.  
  51. initcop:move.l        #bobsplane,d0
  52.     move.l        #bobsplane+40,d1
  53.     move.w        d0,pl+6        ;put bobsplane
  54.     swap        d0        ;pointers
  55.     move.w        d1,pl+14    ;in copperlist
  56.     swap        d1
  57.     move.w        d0,pl+2
  58.     move.w        d1,pl+10
  59.     rts
  60.  
  61. newirq:    movem.l        d0-d7/a0-a6,-(a7);Save regs
  62.     bsr        bounce
  63.     bsr        bobs
  64.     bsr        scroll
  65.     movem.l        (a7)+,d0-d7/a0-a6;Restore regs
  66.     dc.w        $4ef9        ;Code for 'JUMP'
  67. oldirq:    dc.l        0        ;Jump to oldirq
  68.  
  69. scroll:    move.l        gfxbase,a6
  70.     move.l        #2,d0        ;dx, 2 pixels to the left
  71.     clr.l        d1        ;dy
  72.     move.l        #0,d2        ;min x
  73.     move.l        #0,d3        ;min y
  74.     move.l        #383,d4        ;max x
  75.     move.l        #15,d5        ;max y
  76.     move.l        rastport,a1    ;rastport pointer
  77.     jsr        -396(a6)    ;ScrollRaster
  78.     subq.w        #1,scrcount    ;Counter for newtext
  79.     beq        newtext        ;is zero->new char
  80.     rts                ;else->bye ??
  81. newtext:move.w        #5,scrcount    ;newtext delay set
  82.     move.l        gfxbase,a6
  83.     move.l        rastport,a1
  84.     move.l        #374,d0        ;x
  85.     move.l        #8,d1        ;y
  86.     jsr        -240(a6)    ;move
  87.     move.l        stringpointer,a0;pointer to string
  88.     move.l        #1,d0        ;1 char
  89.     jsr        -60(a6)
  90.     addq.l        #1,stringpointer;Next char
  91.     cmpi.l        #endstring,stringpointer
  92.     bne        notend        ;end of string reached
  93.     move.l        #string,stringpointer;Start al over
  94. notend:    rts
  95.  
  96. bouncepointer:    dc.l    bouncedat
  97. bouncey:    dc.w    0
  98.  
  99. bounce:    addq.l        #1,bouncepointer
  100.     cmpi.l        #endbdat,bouncepointer
  101.     bne        not_end
  102.     move.l        #bouncedat,bouncepointer
  103. not_end:move.l        bouncepointer,a0
  104.     move.b        (a0),bouncey+1
  105.     rts
  106.  
  107. bobs:    move.l        #7,d7        ;8 bobs
  108.     lea        xy,a1        ;coord of bobs
  109. loop1:    move.w        (a1),d0        ;get x coord
  110.     move.w        2(a1),d1    ;get y coord
  111.     move.w        #$0900,d2    ; Clear old
  112.     bsr        blit        ;blit it
  113.     addq.l        #8,a1        ;next bob
  114.     dbra        d7,loop1    ;loop
  115.  
  116.     move.l        #7,d7        ;8 bobs
  117.     lea        xy,a1        ;coord
  118. loop:    add.w        #k1,4(a1)    ;next pos in sine
  119.     add.w        #k2,6(a1)    ;next pos
  120.     and.w        #255,4(a1)    ;256 bytes of data
  121.     and.w        #255,6(a1)    ;in sine
  122.     lea        bobsine,a0
  123.     move.w        4(a1),d3
  124.     clr.w        d0
  125.     clr.w        d1
  126.     move.b        (a0,d3.w),d0    ;new x coord
  127.     add.w        #70,d0        ;Center it
  128.     move.w        6(a1),d3
  129.     move.b        (a0,d3.w),d1    ;new y coord
  130.     add.w        #14,d1        ;Center it
  131.     lsl.w        #1,d1        ;x2 coz 2 bitplanes
  132.     add.w        bouncey,d1
  133.     move.w        d0,(a1)        ;save coord 
  134.     move.w        d1,2(a1)
  135.     move.w        #$0dfc,d2    ;blit on
  136.     bsr        blit        ;blit it
  137.     addq.l        #8,a1
  138.     dbra        d7,loop
  139.     rts
  140.  
  141. ;    Blit Routine X coord in d0
  142. ;    Y coord in d1
  143. ;    blitmode in d2
  144.  
  145. blit:    movem.l        d0-d7/a0-a6,-(a7)
  146.     cmpi.w        #380,d1
  147.     blt        is_fine
  148.     move.w        #380,d1
  149. is_fine:bsr        waitblt        ;blitter still in use
  150.     clr.l        d7
  151.     move.w        d0,d7        ;calculate
  152.     and.w        #15,d0        ;all
  153.     lsl.w        #8,d0        ;blitter
  154.     lsl.w        #4,d0        ;data
  155.     or.w        d0,d2        ;from x
  156.     move.w        d2,$dff040    ;and
  157.     lsr.l        #4,d7        ;y
  158.     lsl.l        #1,d7        ;coord
  159.     move.l        #bobsplane,d2
  160.     add.l        d7,d2
  161.     mulu        #40,d1        ;40 is screenwidth
  162.     add.l        d1,d2
  163.  
  164.     move.w        #0,$dff042        ;BLTCON0
  165.     move.l        #$ffff0000,$dff044    ;BLTMASK
  166.     move.l        #dat,$dff050        ;BLTBDAT
  167.     move.l        d2,$dff04c        ;BLTADAT
  168.     move.l        d2,$dff054        ;BLTDDAT
  169.     move.w        #-2,$dff064        ;BLTBMOD
  170.     move.w        #36,$dff062        ;BLTAMOD
  171.     move.w        #36,$dff066         ;BLTDMOD
  172.     move.w        #32*64+2,$dff058
  173.     bsr        waitblt
  174.     movem.l        (a7)+,d0-d7/a0-a6
  175.     rts
  176. waitblt:btst        #14,$dff002
  177.     bne        waitblt
  178.     rts
  179.  
  180. k1 = 1
  181. k2 = 1
  182. cx = 32
  183. cy = 32
  184. k = 64
  185.  
  186. xy:    dc.w    0,0,0,k
  187.     dc.w    0,0,cx,cy+k
  188.     dc.w    0,0,2*cx,2*cy+k
  189.     dc.w    0,0,3*cx,3*cy+k
  190.     dc.w    0,0,4*cx,4*cy+k
  191.     dc.w    0,0,5*cx,5*cy+k
  192.     dc.w    0,0,6*cx,6*cy+k
  193.     dc.w    0,0,7*cx,7*cy+k        ;coord and pos of bobs
  194.  
  195.  
  196. newcop:    dc.w    $0092,$0038,$0094,$00d0    ;DFFSTART,DFFSTOP->Normal
  197.     dc.w    $008e,$296a,$0090,$29fa    ;DIWSTART,DIWSTOP
  198.     dc.w    $0096,$0020,$0100,$0000    ;Sprites off,planes off
  199.     dc.w    $0108,$0028,$010a,$0028    ;BPL1MOD,BPL2MOD
  200.     dc.w    $0180,$0000,$0182,$0e45
  201.     dc.w    $0184,$0b22,$0186,$0800    ;Colors
  202. pl:    dc.w    $00e0,$0000,$00e2,$0000    ;Bitplane 1 pointers
  203.     dc.w    $00e4,$0000,$00e6,$0000    ;Bitplane 2 pointers
  204.     dc.w    $3001,$fffe        ;wait till line 48 = $30
  205.     dc.w    $0100,$2000        ;2 bitplanes on
  206.     dc.w    $ff01,$fffe        ;wait till line 255= $ff
  207.     dc.w    $0100,$0000        ;all bitplanes of
  208.     dc.w    $ffdf,$fffe        ;wait till last NTSC line
  209.  
  210.     dc.w    $0092,$0028,$0094,$00d8    ;DFFSTART,DFFSTOP->OverScan
  211.     dc.w    $0108,$0002,$010a,$0002    ;BPL1MOD,BPL2MOD
  212.     dc.w    $0180,$0000,$0182,$0f00    ;Colors
  213. planes:    dc.w    $00e0,$0000,$00e2,$0000    ;Plane1 low,high word
  214.     dc.w    $0001,$fffe        ;Wait till line 80 reached
  215.     dc.w    $0100,$1000        ;Bitplane 1 on
  216.     dc.w    $0107,$fffe,$0182,$0f11
  217.     dc.w    $0207,$fffe,$0182,$0f22
  218.     dc.w    $0307,$fffe,$0182,$0f33
  219.     dc.w    $0407,$fffe,$0182,$0f44
  220.     dc.w    $0507,$fffe,$0182,$0f55
  221.     dc.w    $0607,$fffe,$0182,$0f66
  222.     dc.w    $0707,$fffe,$0182,$0f77
  223.     dc.w    $0807,$fffe,$0182,$0f88
  224.     dc.w    $0907,$fffe,$0182,$0f99
  225.     dc.w    $0a07,$fffe,$0182,$0faa
  226.     dc.w    $0b07,$fffe,$0182,$0fbb
  227.     dc.w    $0c07,$fffe,$0182,$0fcc
  228.     dc.w    $0d07,$fffe,$0182,$0fdd
  229.     dc.w    $0e07,$fffe,$0182,$0fee
  230.     dc.w    $0f07,$fffe,$0182,$0fff    ;Color changes in scroll
  231.     dc.w    $1001,$fffe        ;Wait till line 208 reached
  232.     dc.w    $0100,$0000        ;Bitplanes off
  233.     dc.w    $0180,$0000        ;background=black
  234.     dc.w    $ffff,$fffe        ;Wait till end
  235.  
  236. bobsplane:
  237.     blk.b    256*40*2,0        ;memory for the bob bitplane
  238.  
  239. osargs:    dc.w    0,0,384,16        ;x-min,y-min,width,height
  240.     dc.w    1            ;depth 1 bitplane
  241.     dc.b    0,1            ;detailpen,blockpen
  242.     dc.w    0,15            ;viewmodes,type=customscreen
  243.     dc.l    textattr,0        ;textattr,title=none
  244.     dc.l    0,0            ;gadgets,bitmap
  245. textattr:
  246.     dc.l    fontname        ;Fontname
  247.     dc.w    9            ;fontsize
  248.     dc.b    0            ;Style=normal
  249.     dc.b    1            ;flags=romfont
  250.  
  251. scrcount:    dc.w    1
  252. oldcop:        dc.l    0
  253. gfxbase:    dc.l    0
  254. intbase:    dc.l    0
  255. rastport:    dc.l    0
  256. screenbase:    dc.l    0
  257. stringpointer:    dc.l    string
  258. intname:    dc.b    "intuition.library",0
  259. gfxname:    dc.b    "graphics.library",0
  260. fontname:    dc.b    "topaz.font",0
  261. string:
  262.  dc.b    " THE TIMECIRCLE ... THIS NICE LITTLE BOB-BOUNCE-SCROLLER"
  263.  DC.B    " WAS CREATED BY BRIAN POSTMA FOR THE UGA NEWSFLASH "
  264.  DC.B    "MAGAZINE ......             "
  265. endstring:
  266. even
  267. bobsine:
  268.  dc.b $50,$52,$54,$56,$58,$5A,$5C,$5E
  269.  dc.b $60,$62,$63,$65,$67,$69,$6B,$6D
  270.  dc.b $6F,$70,$72,$74,$76,$77,$79,$7B
  271.  dc.b $7C,$7E,$80,$81,$83,$84,$86,$87
  272.  dc.b $89,$8A,$8B,$8D,$8E,$8F,$90,$91
  273.  dc.b $93,$94,$95,$96,$97,$97,$98,$99
  274.  dc.b $9A,$9B,$9B,$9C,$9D,$9D,$9E,$9E
  275.  dc.b $9E,$9F,$9F,$9F,$A0,$A0,$A0,$A0
  276.  dc.b $A0,$A0,$A0,$A0,$A0,$9F,$9F,$9F
  277.  dc.b $9E,$9E,$9E,$9D,$9D,$9C,$9B,$9B
  278.  dc.b $9A,$99,$98,$97,$97,$96,$95,$94
  279.  dc.b $93,$91,$90,$8F,$8E,$8D,$8B,$8A
  280.  dc.b $89,$87,$86,$84,$83,$81,$80,$7E
  281.  dc.b $7C,$7B,$79,$77,$76,$74,$72,$70
  282.  dc.b $6F,$6D,$6B,$69,$67,$65,$63,$62
  283.  dc.b $60,$5E,$5C,$5A,$58,$56,$54,$52
  284.  dc.b $50,$4E,$4C,$4A,$48,$46,$44,$42
  285.  dc.b $40,$3E,$3D,$3B,$39,$37,$35,$33
  286.  dc.b $31,$30,$2E,$2C,$2A,$29,$27,$25
  287.  dc.b $24,$22,$20,$1F,$1D,$1C,$1A,$19
  288.  dc.b $17,$16,$15,$13,$12,$11,$10,$F
  289.  dc.b $D,$C,$B,$A,$9,$9,$8,$7
  290.  dc.b $6,$5,$5,$4,$3,$3,$2,$2
  291.  dc.b $2,$1,$1,$1,$0,$0,$0,$0
  292.  dc.b $0,$0,$0,$0,$0,$1,$1,$1
  293.  dc.b $2,$2,$2,$3,$3,$4,$5,$5
  294.  dc.b $6,$7,$8,$9,$9,$A,$B,$C
  295.  dc.b $D,$F,$10,$11,$12,$13,$15,$16
  296.  dc.b $17,$19,$1A,$1C,$1D,$1F,$20,$22
  297.  dc.b $24,$25,$27,$29,$2A,$2C,$2E,$30
  298.  dc.b $31,$33,$35,$37,$39,$3B,$3D,$3E
  299.  dc.b $40,$42,$44,$46,$48,$4A,$4C,$4E
  300.  
  301. dat:
  302.  dc.w    $0,$0,$820,$FE0,$2008,$3FF8,$4C04
  303.  dc.w    $73FC,$1800,$67FC,$9002,$EFFE,$0,$FFFE,$2
  304.  dc.w    $FFFE,$2,$FFFE,$6,$FFFE,$6,$FFFE,$800C,$FFFC
  305.  dc.w    $1C,$7FFC,$4038,$7FF8,$20F0,$3FF0,$BC0,$FC0
  306.  
  307. bouncedat:
  308.  dc.b    100,84,70,58,48,40,34,30,26,24,22,20,20
  309.  dc.b    18,18,16,16,14,14,14,12,12
  310.  dc.b    12,12,12,14,14,14,16,16
  311.  dc.b    18,18,20,20,22,24,26,30,34,40,48,58,70,84
  312. endbdat:
  313.